<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <title>渲染页面</title>
    <style>
        p {
            margin: 0;
        }

        img {
            width: 100px;
        }

        .products {
            display: flex;
            flex-wrap: wrap;
            width: 600px;
            height: 360px;
            margin: 0 auto;
            background-color: whitesmoke;
        }

        .item {
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            width: 150px;
            height: 180px;
            box-sizing: border-box;
            /* background-color: aqua; */
        }

        .item:hover {
            box-shadow: 0 0 7px 0px;
        }

        .item .price {
            font-size: 18px;
            color: red;
        }
    </style>
</head>

<body>
    <div class="products">
        <div class="item">
            <img src="./images/1.jpg" alt="">
            <p class="name">aa</p>
            <p class="price">12</p>
        </div>
    </div>
    <script>
        // 渲染数据
        const dataList = [
            { picture: './images/1.jpg', name: '精品茶杯', price: 100 },
            { picture: './images/2.jpg', name: '茶杯礼盒套装', price: 89 },
            { picture: './images/3.jpg', name: '精致茶壶', price: 99 },
            { picture: './images/4.jpg', name: '碗壶套装', price: 124 },
            { picture: './images/5.jpg', name: '陶瓷茶碗', price: 122 },
            { picture: './images/4.jpg', name: '碗壶套装', price: 123 },
            { picture: './images/5.jpg', name: '陶瓷茶碗', price: 123 },
        ]
        // 声明一个字符串变量
        let str = ''
        // 遍历数据
        dataList.forEach(item => {
            // 对象解构
            const { picture, name, price } = item
            str += `
            <div class="item">
                <img src="${picture}" alt="">
                <p class="name">${name}</p>
                <p class="price">￥${price}</p>
            </div>
            `
        })
        // 生成的字符串添加给products
        document.querySelector('.products').innerHTML=str
    </script>
</body>

</html>